package com.yang.javaws;

import java.util.List;

import javax.xml.ws.Endpoint;

import org.junit.Test;

import com.yang.javaws.axis2.stub.TestServicePortType;
import com.yang.javaws.java6WebService.stub.Men;
import com.yang.javaws.java6WebService.stub.TestServiceService;


public class Java6WebService {
	
	public static void main(String[] args) {
		//启动服务
		//Endpoint.publish("http://192.168.1.251:8989/ws/TestService", new com.yang.javaws.java6WebService.TestService());
		//启动服务
		Endpoint.publish("http://127.0.0.1:8000/ws/TestService", new com.yang.javaws.java6WebService.TestService());
	}
	/**
	 * 调用javawebservice发布的服务
	 * 通过生成本地stub来调用webservice
	 * 命令：wsimport -p com.yang.javaws.stub -keep http://localhost:8085/ws/TestService?wsdl
	 * 
	 */
	@Test
	public void testClient(){
		com.yang.javaws.java6WebService.stub.TestService service = (com.yang.javaws.java6WebService.stub.TestService) new TestServiceService().getTestServicePort();
		System.out.println("getInt----->" + service.getInt(2));
		List<String> list = service.getList();
		System.out.println("getList----->");
		for(String temp : list){
			System.out.println(temp);
		}
		
		Men men = service.getObject();
		System.out.println("getObject----->" + men);
	}
	
	/**
	 * 调用axis2发布的服务
	 */
	@Test
	public void testAxis(){
		TestServicePortType service =  new com.yang.javaws.axis2.stub.TestService().getTestServiceHttpSoap11Endpoint();
		System.out.println("getName----->" + service.getName());
		System.out.println("getName----->" + service.add(1,2));
		System.out.println("getName----->" + service.get(3));
		
	}
}
